<template>
  <div>
    <table>
      <tr>
        <td>姓名</td>
        <td>{{student.name}}</td>
        <td>性别</td>
        <td>{{student.sex==1?'男':'女'}}</td>
      </tr>
      <tr>
        <td>学历</td>
        <td>{{student.education}}</td>
        <td>毕业时间</td>
        <td>{{student.graduate_date}}</td>
      </tr>
      <tr>
        <td>手机号码</td>
        <td>{{student.phone}}</td>
        <td>毕业院校</td>
        <td>{{student.college}}</td>
      </tr>
    </table>
    <table style="margin-top: 10px;">
      <tr>
        <td>工作状态</td>
        <td>{{resume.job_status}}</td>
      </tr>
      <tr>
        <td>自我评价</td>
        <td>{{resume.evaluate}}</td>
      </tr>
      <tr>
        <td>技能描述</td>
        <td>{{resume.skill}}</td>
      </tr>
    </table>
    <p v-if="projects.length>0">项目经验</p>
    <table v-for="(item,index) in projects" :key="index" style="margin-top: 10px">
      <tr>
        <td>项目名称{{index+1}}</td>
        <td>{{item.name}}</td>
      </tr>
      <tr>
        <td>描述</td>
        <td>{{item.description}}</td>
      </tr>
      <tr>
        <td>起止日期</td>
        <td>{{item.start_date}}至{{item.end_date}}</td>
      </tr>
    </table>
    <p v-if="trains.length>0">培训经历</p>
    <table v-for="(item,index) in trains" :key="index" style="margin-top: 10px">
      <tr>
        <td>培训课程{{index+1}}</td>
        <td>{{item.course}}</td>
      </tr>
      <tr>
        <td>培训公司</td>
        <td>{{item.company}}</td>
      </tr>
      <tr>
        <td>起止日期</td>
        <td>{{item.start_date}}至{{item.end_date}}</td>
      </tr>
    </table>
    <p v-if="intentions.length>0">求职意向</p>
    <table v-for="(item,index) in intentions" :key="index" style="margin-top: 10px">
      <tr>
        <td>职位名称{{index+1}}</td>
        <td>{{item.name}}</td>
        <td>薪资要求</td>
        <td>{{item.salary}}</td>
      </tr>
      <tr>
        <td>工作城市</td>
        <td>{{item.city}}</td>
        <td>工作类型</td>
        <td>{{item.type}}</td>
      </tr>
      <tr>
        <td>工作行业</td>
        <td colspan="3">{{item.industry}}</td>
      </tr>
    </table>

    <p v-if="certificates.length>0">获得荣誉</p>
    <table v-for="(item,index) in certificates" :key="index" style="margin-top: 10px">
      <tr>
        <td>证书名称{{index+1}}</td>
        <td>{{item.name}}</td>
      </tr>
      <tr>
        <td>获得时间</td>
        <td>{{item.obtain_date}}</td>
      </tr>
      <tr>
        <td>附件</td>
        <td>
          <img style="width: 100px;height: 100px;" v-if="item.file != null" :src="item.file">
          <span v-else>暂无上传</span>
        </td>
      </tr>
    </table>

    <p v-if="experiences.length>0">工作经历</p>
    <table v-for="(item,index) in experiences" :key="index" style="margin-top: 10px">
      <tr>
        <td>所在公司{{index+1}}</td>
        <td>{{item.company}}</td>
        <td>职位</td>
        <td>{{item.post}}</td>
      </tr>
      <tr>
        <td>薪资</td>
        <td>{{item.salary}}</td>
        <td>起止日期</td>
        <td>{{item.join_date}}-{{item.leave_date}}</td>
      </tr>
      <tr>
        <td>职位描述</td>
        <td colspan="3">{{item.description}}</td>
      </tr>
    </table>

  </div>
</template>

<script>
  export default {
    name: "ResumeDetail",
    props: ['id'],
    data() {
      return {
        resume: {},
        student: {},
        trains: [],
        certificates: [],
        projects: [],
        intentions: [],
        experiences: [],
      }
    },
    mounted() {
      this.resume1();
      this.train1();
      this.certificate1();
      this.project1();
      this.intention1();
      this.experience1();
    },
    methods: {
      resume1() {
        this.getRequest("/resume/detail/?id=" + this.id).then(res => {
          this.resume = res.obj;
          console.log(this.resume, "简历");
          this.student1(this.resume.student_id);
        })
      },
      intention1() {
        this.postRequest("/intention/query", {
          resume_id: this.id
        }).then(res => {
          this.intentions = res;
          console.log(this.intentions, "意向");

        })
      },
      student1(studentId) {
        this.getRequest("/student/detail/?id=" + studentId).then(res => {
          this.student = res.obj;
          console.log(this.student, "学生");

        })
      },
      train1() {
        this.postRequest("/train/query", {
          resume_id: this.id
        }).then(res => {
          this.trains = res;
        })
      },
      certificate1() {
        this.postRequest("/certificate/queryByCon", {
          resume_id: this.id
        }).then(res => {
          this.certificates = res;
        })
      },
      project1() {
        this.postRequest("/project/query", {
          resume_id: this.id
        }).then(res => {
          this.projects = res;
        })
      },
      experience1() {
        this.postRequest("/project/query", {
          resume_id: this.id
        }).then(res => {
          this.experiences = res;
        })
      }
    }
  }
</script>

<style scoped>
  table {
    border-collapse: collapse;
    margin: 0 auto;
    text-align: center;
    width: 98%;
  }

  table td,
  table th {
    border: 1px solid #dddddd;
    color: #666;
    font-size: 14px;
    padding: 7px 0px;
  }

  table td:nth-child(odd) {
    background-color: #f0f0f0;
    width: 90px;
  }

  table td:nth-child(even) {
    text-align: left;
    padding-left: 10px;
  }

  p {
    margin: 10px 0px;
    padding: 0 20px;
    font-size: 14px;
  }
</style>